package com.web.portal.dao;

import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.web.portal.entity.TutoringCenter;
@Repository("tutoringCenterDao")
public class TutoringCenterDaoImpl extends WebportalBaseDao<TutoringCenter> implements TutoringCenterDao {
private static final Logger LOG =Logger.getLogger(TutoringCenterDaoImpl.class);
	public List<TutoringCenter> listItems(TutoringCenter instance) {
		// TODO Auto-generated method stub
		LOG.debug("getting list of Tutoring center from session");
		try{
			List<TutoringCenter> result =(List<TutoringCenter>)getSession().createQuery("from TutoringCenter").list();
			if(result.isEmpty()){
			LOG.debug("Records are empty for Tutoring Center............");
			}
			LOG.debug("Successfully fetched record for Tutoring center from database.....................");
			return result;
					
		}catch(HibernateException e){
			LOG.debug("Unable to fetch from database.....................................");
			throw e;
		}
		
		
	}

	@Override
	protected void populateCriteria(
			Map<? extends Enum<?>, Object> searchCriteria, Criteria criteria) {
	if(searchCriteria.containsKey(TutoringCenterSearchType.ID)){
		criteria.add(Restrictions.eq("id", searchCriteria.get(TutoringCenterSearchType.ID)));
	}
		
	}

}
